package com.riaevolution.components
{
	import mx.formatters.NumberFormatter;

	public class DniFormatter extends NumberFormatter
	{
		public var Separator:String = ".";
		public function DniFormatter()
		{
			//TODO: implement function
			super();
		}
		override public function format(value:Object):String {
            //Validate value - it must be a nonzero length string.
            var number:Number = value as Number;
			if(isNaN(number)) {    
                    // Return empty string and error message for zero-length string.
                    error="Empty String";
                    return "";
            }
            var formatedStr:String = "";
            var charlen:Number = number.toString().length;
            
			var cents : String = number.toString().slice(charlen-3,charlen);
			var thousands :String = number.toString().slice(charlen-6,charlen-3)+Separator;
			var millon:String = "";            
            if(charlen>=7){
            	 millon = number.toString().slice(0,charlen-6)+Separator;
            }
            return millon+thousands+cents;
            //return number.toString();
		}
	}
}